﻿namespace HRM.CORE
{
    using APP.HELPER.Data.Helper;
    using DevExpress.XtraEditors;
    using System; using Extra.ERP;
    using System.ComponentModel;
    using System.Data;
    using System.Data.SqlClient;
    using System.Windows.Forms; using Common;

    public class HRM_EMPLOYEE_RELATIVE
    {
        private string m_Address;
        private DateTime m_Birthday;
        private string m_Email;
        private string m_EmployeeCode;
        private string m_IncomeTaxCode;
        private bool m_IsDepend;
        private Guid m_PersonID;
        private string m_PersonName;
        private string m_Phone;
        private string m_Relative;

        public HRM_EMPLOYEE_RELATIVE()
        {
            this.m_PersonID = Guid.Empty;
            this.m_EmployeeCode = "";
            this.m_PersonName = "";
            this.m_Relative = "";
            this.m_Birthday = DateTime.Now;
            this.m_Address = "";
            this.m_Email = "";
            this.m_Phone = "";
            this.m_IncomeTaxCode = "";
            this.m_IsDepend = true;
        }

        public HRM_EMPLOYEE_RELATIVE(Guid PersonID, string EmployeeCode, string PersonName, string Relative, DateTime Birthday, string Address, string Email, string Phone, string IncomeTaxCode, bool IsDepend)
        {
            this.m_PersonID = PersonID;
            this.m_EmployeeCode = EmployeeCode;
            this.m_PersonName = PersonName;
            this.m_Relative = Relative;
            this.m_Birthday = Birthday;
            this.m_Address = Address;
            this.m_Email = Email;
            this.m_Phone = Phone;
            this.m_IncomeTaxCode = IncomeTaxCode;
            this.m_IsDepend = IsDepend;
        }

        public string Delete()
        {
            string[] myParams = new string[] { "@EmployeeCode" };
            object[] myValues = new object[] { this.EmployeeCode };
            SqlHelper helper = new SqlHelper();
            return helper.ExecuteNonQuery("HRM_EMPLOYEE_RELATIVE_Delete", myParams, myValues);
        }

        public string Delete(string EmployeeCode)
        {
            string[] myParams = new string[] { "@EmployeeCode" };
            object[] myValues = new object[] { EmployeeCode };
            SqlHelper helper = new SqlHelper();
            return helper.ExecuteNonQuery("HRM_EMPLOYEE_RELATIVE_Delete", myParams, myValues);
        }

        public string Delete(SqlTransaction myTransaction, string EmployeeCode)
        {
            string[] myParams = new string[] { "@EmployeeCode" };
            object[] myValues = new object[] { EmployeeCode };
            SqlHelper helper = new SqlHelper();
            return helper.ExecuteNonQuery(myTransaction, "HRM_EMPLOYEE_RELATIVE_Delete", myParams, myValues);
        }

        public string Delete(SqlConnection myConnection, string EmployeeCode, string AllowanceCode)
        {
            string[] myParams = new string[] { "@EmployeeCode" };
            object[] myValues = new object[] { EmployeeCode };
            SqlHelper helper = new SqlHelper();
            return helper.ExecuteNonQuery(myConnection, "HRM_EMPLOYEE_RELATIVE_Delete", myParams, myValues);
        }

        private void DispError(object sender, SqlHelperException e)
        {
            XtraMessageBox.Show(e.Message, "Th\x00f4ng B\x00e1o", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
        }

        public bool Exist(Guid PersonID)
        {
            bool hasRows = false;
            string[] myParams = new string[] { "@PersonID" };
            object[] myValues = new object[] { PersonID };
            SqlHelper helper = new SqlHelper();
            SqlDataReader reader = helper.ExecuteReader("HRM_EMPLOYEE_RELATIVE_Get", myParams, myValues);
            if (reader != null)
            {
                hasRows = reader.HasRows;
                reader.Close();
                helper.Close();
                reader = null;
            }
            return hasRows;
        }

        public string Get(Guid PersonID)
        {
            string str = "";
            string[] myParams = new string[] { "@PersonID" };
            object[] myValues = new object[] { PersonID };
            SqlHelper helper = new SqlHelper();
            SqlDataReader reader = helper.ExecuteReader("HRM_EMPLOYEE_RELATIVE_Get", myParams, myValues);
            if (reader != null)
            {
                while (reader.Read())
                {
                    this.m_PersonID = reader.GetGuid(reader.GetOrdinal("PersonID"));
                    this.m_EmployeeCode = Convert.ToString(reader["EmployeeCode"]);
                    this.m_PersonName = Convert.ToString(reader["PersonName"]);
                    this.m_Relative = Convert.ToString(reader["Relative"]);
                    this.m_Birthday = Convert.ToDateTime(reader["Birthday"]);
                    this.m_Address = Convert.ToString(reader["Address"]);
                    this.m_Email = Convert.ToString(reader["Email"]);
                    this.m_Phone = Convert.ToString(reader["Phone"]);
                    this.m_IncomeTaxCode = Convert.ToString(reader["IncomeTaxCode"]);
                    this.m_IsDepend = Convert.ToBoolean(reader["IsDepend"]);
                    str = "OK";
                }
                reader.Close();
                helper.Close();
                reader = null;
            }
            return str;
        }

        public string Get(SqlConnection myConnection, Guid PersonID)
        {
            string str = "";
            string[] myParams = new string[] { "@PersonID" };
            object[] myValues = new object[] { PersonID };
            SqlHelper helper = new SqlHelper();
            SqlDataReader reader = helper.ExecuteReader(myConnection, "HRM_EMPLOYEE_RELATIVE_Get", myParams, myValues);
            if (reader != null)
            {
                while (reader.Read())
                {
                    this.m_PersonID = reader.GetGuid(reader.GetOrdinal("PersonID"));
                    this.m_EmployeeCode = Convert.ToString(reader["EmployeeCode"]);
                    this.m_PersonName = Convert.ToString(reader["PersonName"]);
                    this.m_Relative = Convert.ToString(reader["Relative"]);
                    this.m_Birthday = Convert.ToDateTime(reader["Birthday"]);
                    this.m_Address = Convert.ToString(reader["Address"]);
                    this.m_Email = Convert.ToString(reader["Email"]);
                    this.m_Phone = Convert.ToString(reader["Phone"]);
                    this.m_IncomeTaxCode = Convert.ToString(reader["IncomeTaxCode"]);
                    this.m_IsDepend = Convert.ToBoolean(reader["IsDepend"]);
                    str = "OK";
                }
                reader.Close();
                helper.Close();
                reader = null;
            }
            return str;
        }

        public string Get(SqlTransaction myTransaction, Guid PersonID)
        {
            string str = "";
            string[] myParams = new string[] { "@PersonID" };
            object[] myValues = new object[] { PersonID };
            SqlHelper helper = new SqlHelper();
            SqlDataReader reader = helper.ExecuteReader(myTransaction, "HRM_EMPLOYEE_RELATIVE_Get", myParams, myValues);
            if (reader != null)
            {
                while (reader.Read())
                {
                    this.m_PersonID = reader.GetGuid(reader.GetOrdinal("PersonID"));
                    this.m_EmployeeCode = Convert.ToString(reader["EmployeeCode"]);
                    this.m_PersonName = Convert.ToString(reader["PersonName"]);
                    this.m_Relative = Convert.ToString(reader["Relative"]);
                    this.m_Birthday = Convert.ToDateTime(reader["Birthday"]);
                    this.m_Address = Convert.ToString(reader["Address"]);
                    this.m_Email = Convert.ToString(reader["Email"]);
                    this.m_Phone = Convert.ToString(reader["Phone"]);
                    this.m_IncomeTaxCode = Convert.ToString(reader["IncomeTaxCode"]);
                    this.m_IsDepend = Convert.ToBoolean(reader["IsDepend"]);
                    str = "OK";
                }
                reader.Close();
                helper.Close();
                reader = null;
            }
            return str;
        }

        public DataTable GetList(string EmployeeCode)
        {
            string[] myParams = new string[] { "@EmployeeCode" };
            object[] myValues = new object[] { EmployeeCode };
            SqlHelper helper = new SqlHelper();
            return helper.ExecuteDataTable("HRM_EMPLOYEE_RELATIVE_GetList", myParams, myValues);
        }

        public string Insert()
        {
            string[] myParams = new string[] { "@PersonID", "@EmployeeCode", "@PersonName", "@Relative", "@Birthday", "@Address", "@Email", "@Phone", "@IncomeTaxCode", "@IsDepend" };
            object[] myValues = new object[] { this.m_PersonID, this.m_EmployeeCode, this.m_PersonName, this.m_Relative, this.m_Birthday, this.m_Address, this.m_Email, this.m_Phone, this.m_IncomeTaxCode, this.m_IsDepend };
            SqlHelper helper = new SqlHelper();
            return helper.ExecuteNonQuery("HRM_EMPLOYEE_RELATIVE_Insert", myParams, myValues);
        }

        public string Insert(SqlTransaction myTransaction)
        {
            string[] myParams = new string[] { "@PersonID", "@EmployeeCode", "@PersonName", "@Relative", "@Birthday", "@Address", "@Email", "@Phone", "@IncomeTaxCode", "@IsDepend" };
            object[] myValues = new object[] { this.m_PersonID, this.m_EmployeeCode, this.m_PersonName, this.m_Relative, this.m_Birthday, this.m_Address, this.m_Email, this.m_Phone, this.m_IncomeTaxCode, this.m_IsDepend };
            SqlHelper helper = new SqlHelper();
            return helper.ExecuteNonQuery(myTransaction, "HRM_EMPLOYEE_RELATIVE_Insert", myParams, myValues);
        }

        public string Insert(Guid PersonID, string EmployeeCode, string PersonName, string Relative, DateTime Birthday, string Address, string Email, string Phone, string IncomeTaxCode, bool IsDepend)
        {
            string[] myParams = new string[] { "@PersonID", "@EmployeeCode", "@PersonName", "@Relative", "@Birthday", "@Address", "@Email", "@Phone", "@IncomeTaxCode", "@IsDepend" };
            object[] myValues = new object[] { PersonID, EmployeeCode, PersonName, Relative, Birthday, Address, Email, Phone, IncomeTaxCode, IsDepend };
            SqlHelper helper = new SqlHelper();
            return helper.ExecuteNonQuery("HRM_EMPLOYEE_RELATIVE_Insert", myParams, myValues);
        }

        public string Insert(SqlConnection myConnection, Guid PersonID, string EmployeeCode, string PersonName, string Relative, DateTime Birthday, string Address, string Email, string Phone, string IncomeTaxCode, bool IsDepend)
        {
            string[] myParams = new string[] { "@PersonID", "@EmployeeCode", "@PersonName", "@Relative", "@Birthday", "@Address", "@Email", "@Phone", "@IncomeTaxCode", "@IsDepend" };
            object[] myValues = new object[] { PersonID, EmployeeCode, PersonName, Relative, Birthday, Address, Email, Phone, IncomeTaxCode, IsDepend };
            SqlHelper helper = new SqlHelper();
            return helper.ExecuteNonQuery(myConnection, "HRM_EMPLOYEE_RELATIVE_Insert", myParams, myValues);
        }

        public string Insert(SqlTransaction myTransaction, Guid PersonID, string EmployeeCode, string PersonName, string Relative, DateTime Birthday, string Address, string Email, string Phone, string IncomeTaxCode, bool IsDepend)
        {
            string[] myParams = new string[] { "@PersonID", "@EmployeeCode", "@PersonName", "@Relative", "@Birthday", "@Address", "@Email", "@Phone", "@IncomeTaxCode", "@IsDepend" };
            object[] myValues = new object[] { PersonID, EmployeeCode, PersonName, Relative, Birthday, Address, Email, Phone, IncomeTaxCode, IsDepend };
            SqlHelper helper = new SqlHelper();
            return helper.ExecuteNonQuery(myTransaction, "HRM_EMPLOYEE_RELATIVE_Insert", myParams, myValues);
        }

        public string Update()
        {
            string[] myParams = new string[] { "@PersonID", "@EmployeeCode", "@PersonName", "@Relative", "@Birthday", "@Address", "@Email", "@Phone", "@IncomeTaxCode", "@IsDepend" };
            object[] myValues = new object[] { this.m_PersonID, this.m_EmployeeCode, this.m_PersonName, this.m_Relative, this.m_Birthday, this.m_Address, this.m_Email, this.m_Phone, this.m_IncomeTaxCode, this.m_IsDepend };
            SqlHelper helper = new SqlHelper();
            return helper.ExecuteNonQuery("HRM_EMPLOYEE_RELATIVE_Update", myParams, myValues);
        }

        public string Update(SqlTransaction myTransaction)
        {
            string[] myParams = new string[] { "@PersonID", "@EmployeeCode", "@PersonName", "@Relative", "@Birthday", "@Address", "@Email", "@Phone", "@IncomeTaxCode", "@IsDepend" };
            object[] myValues = new object[] { this.m_PersonID, this.m_EmployeeCode, this.m_PersonName, this.m_Relative, this.m_Birthday, this.m_Address, this.m_Email, this.m_Phone, this.m_IncomeTaxCode, this.m_IsDepend };
            SqlHelper helper = new SqlHelper();
            return helper.ExecuteNonQuery(myTransaction, "HRM_EMPLOYEE_RELATIVE_Update", myParams, myValues);
        }

        public string Update(Guid PersonID, string EmployeeCode, string PersonName, string Relative, DateTime Birthday, string Address, string Email, string Phone, string IncomeTaxCode, bool IsDepend)
        {
            string[] myParams = new string[] { "@PersonID", "@EmployeeCode", "@PersonName", "@Relative", "@Birthday", "@Address", "@Email", "@Phone", "@IncomeTaxCode", "@IsDepend" };
            object[] myValues = new object[] { PersonID, EmployeeCode, PersonName, Relative, Birthday, Address, Email, Phone, IncomeTaxCode, IsDepend };
            SqlHelper helper = new SqlHelper();
            return helper.ExecuteNonQuery("HRM_EMPLOYEE_RELATIVE_Update", myParams, myValues);
        }

        public string Update(SqlConnection myConnection, Guid PersonID, string EmployeeCode, string PersonName, string Relative, DateTime Birthday, string Address, string Email, string Phone, string IncomeTaxCode, bool IsDepend)
        {
            string[] myParams = new string[] { "@PersonID", "@EmployeeCode", "@PersonName", "@Relative", "@Birthday", "@Address", "@Email", "@Phone", "@IncomeTaxCode", "@IsDepend" };
            object[] myValues = new object[] { PersonID, EmployeeCode, PersonName, Relative, Birthday, Address, Email, Phone, IncomeTaxCode, IsDepend };
            SqlHelper helper = new SqlHelper();
            return helper.ExecuteNonQuery(myConnection, "HRM_EMPLOYEE_RELATIVE_Update", myParams, myValues);
        }

        public string Update(SqlTransaction myTransaction, Guid PersonID, string EmployeeCode, string PersonName, string Relative, DateTime Birthday, string Address, string Email, string Phone, string IncomeTaxCode, bool IsDepend)
        {
            string[] myParams = new string[] { "@PersonID", "@EmployeeCode", "@PersonName", "@Relative", "@Birthday", "@Address", "@Email", "@Phone", "@IncomeTaxCode", "@IsDepend" };
            object[] myValues = new object[] { PersonID, EmployeeCode, PersonName, Relative, Birthday, Address, Email, Phone, IncomeTaxCode, IsDepend };
            SqlHelper helper = new SqlHelper();
            return helper.ExecuteNonQuery(myTransaction, "HRM_EMPLOYEE_RELATIVE_Update", myParams, myValues);
        }

        [Category("Column"), DisplayName("Address")]
        public string Address
        {
            get
            {
                return this.m_Address;
            }
            set
            {
                this.m_Address = value;
            }
        }

        [Category("Column"), DisplayName("Birthday")]
        public DateTime Birthday
        {
            get
            {
                return this.m_Birthday;
            }
            set
            {
                this.m_Birthday = value;
            }
        }

        [DisplayName("Email"), Category("Column")]
        public string Email
        {
            get
            {
                return this.m_Email;
            }
            set
            {
                this.m_Email = value;
            }
        }

        [DisplayName("EmployeeCode"), Category("Column")]
        public string EmployeeCode
        {
            get
            {
                return this.m_EmployeeCode;
            }
            set
            {
                this.m_EmployeeCode = value;
            }
        }

        [Category("Column"), DisplayName("IncomeTaxCode")]
        public string IncomeTaxCode
        {
            get
            {
                return this.m_IncomeTaxCode;
            }
            set
            {
                this.m_IncomeTaxCode = value;
            }
        }

        [DisplayName("IsDepend"), Category("Column")]
        public bool IsDepend
        {
            get
            {
                return this.m_IsDepend;
            }
            set
            {
                this.m_IsDepend = value;
            }
        }

        [Category("Primary Key"), DisplayName("PersonID")]
        public Guid PersonID
        {
            get
            {
                return this.m_PersonID;
            }
            set
            {
                this.m_PersonID = value;
            }
        }

        [DisplayName("PersonName"), Category("Column")]
        public string PersonName
        {
            get
            {
                return this.m_PersonName;
            }
            set
            {
                this.m_PersonName = value;
            }
        }

        [DisplayName("Phone"), Category("Column")]
        public string Phone
        {
            get
            {
                return this.m_Phone;
            }
            set
            {
                this.m_Phone = value;
            }
        }

        [Category("Column"), DisplayName("Relative")]
        public string Relative
        {
            get
            {
                return this.m_Relative;
            }
            set
            {
                this.m_Relative = value;
            }
        }
    }
}

